<?php


class PanelAdmina_Controller extends Controller
{
        public function __construct()
	{
		parent::__construct();
                $this->session=new Session();
	}
        public function wyloguj()
        {
                $this->session->delete('zalogowany');
                $this->index();
        }
        public function index()
        {
            if($this->session->get('zalogowany')=='admin')
            {
                    $this->panel_admina();
            }
                //echo $this->render('panel_admina/panel_admina.html');
            else
            {
            $user=new User_Model();
            $tt=$user->sprawdz($this->input->post('haslo'));
            if(empty($tt))
            {
                //$this['informacja']='blad hasla';
                echo $this->render('login/l.html');
            }
            else
            {
                $this->panel_admina();
                $this->session->set('zalogowany','admin');
            }
            }
        }
        public function panel_admina()
        {
            $kat=new Kategoria_Model();
            $kategorie=$kat->pobierz_kategorie_wawa();
            $this['kategorie']=$kategorie;
            echo $this->render('panel_admina/panel_admina.html');
        }
        public function dodaj_kategorie()
        {
            $kategoria=new Kategoria_Model();
            $kategoria->dodaj_kategorie($this->input->post('kategoria'));
            $this->panel_admina();
        }
}
